#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int i,n=0,st=0;
	char s[100];
	gets(s);
	cout<<endl;
	for(i=0;s[i];i++)
		if(s[i]!=' '&&s[i]!=','&&s[i]!='.'&&s[i]!='?'&&s[i]!='!')
		{
			st=1;
			cout<<s[i];
		}
		else
		{
			if(st==1)
			{
				cout<<endl;
				n++;
			}
			st=0;
		}
	if(s[i-1]!=' '&&s[i-1]!=','&&s[i-1]!='.'&&s[i-1]!='?'&&s[i-1]!='!')
		n++;
	cout<<endl<<"Total has "<<n<<" words."<<endl;
	getchar();
	return 0;
}
